package com.lplb.common.redis.test;


import com.lplb.common.redis.utils.RedisUtil;
import com.lplb.common.redis.utils.RedisNoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试接口，  http://localhost:9001/test
 *
 * @author ws
 * @mail 1720696548@qq.com
 * @date 2020/2/21 0021 16:03
 */
@RestController
public class RedisNoController {

    @Autowired
    private RedisNoUtil redisNoGenerate;
    @Autowired
    private RedisUtil redisUtil;


    @GetMapping("/getNo")
    public String getNo() {
        // 获取订单号
        String orderOn = redisNoGenerate.getNo("order-on", 1L);
        // 设置订单有效期30秒
        redisUtil.set("order-on-time" + orderOn, 0, 1800);
        return orderOn;
    }
}
